Skip to main content

3. Linking with an enquiry

When a new enquiry is created, new sessionToken, repairtimeTypeId, job descriptions and maintainence descriptions are generated and saved.

Sequence diagram below illustrates only positive scenario

UseThirdPartyDescription is considered false in either of the below scenarios

  • No repairTypeID found for the vehicle
  • Requesting maintainence descriptions failed or obtained 0 maintainence descriptions
  • Requesting repair descriptions failed or obtained 0 descriptions
  • Total count of repair descriptions and maintainence descriptions arrived to be 0

Stub

HaynesPro automotive doesn't provide a sandbox environment to test the api nor provide any vehicle list that can be used to test the api calls without incurring subsequent data consumption charges. To overcome this limitation and to exercise cost saving during development and testing, we create a stub that mocks the calls to return the datasets that are similar to what is returned by real api.

Stub setup

The prerequisites for seting stub are

  • Inorder for the functions to decide to fetch from stub or real api we need an endpoint to reach prior making call.
  • Also in the event of extending the platform to support more automotive data services (ex:autodata) we need a way to isolate between these services at customer level

Catering to the prerequisites we created a field named integrations in firebase at lease company level whose structure is as below

leaseCompany
| |--> leaseId
| | |--> config
| | | |--> integrations
| | | | |--> enabled
| | | | |--> source
| | | | |--> sourceLabel
| | | | |--> type
| | | | |--> useStub

Data for stub

Creating a data structure in firebase in order to mock the stub would

  • add up more time for the methods to execute.
  • add up the data charges from firebase for read/write operations
  • add more failure scenarios to address on top of ones from haynes

So the data is purely limited to code level.

Construction

  • create a write stream to log the contents to
  • initiate a logger whose output is the file stream
  • Create spec file to do the real api call
  • iterate through the results and create the collection
  • serialize the collection to json format
  • save obtained json to file using the logger
  • copy these files to json file suffixing them with VRM and add them to source codebase

Fetching

  • When an enquiry is created, look for the lease company that the vehicle is contracted to.
  • Fetch the config of respective lease company
  • On the event of config's existence and enable status
  • Look for useStub attribute
  • Look for the data from corresponding vehicle's json file and return
Status: Accepted
Category: Protected
Authored By: Vishwa on Mar 22, 2023